<?php
/**
 *	[TWCMS] (C)2012 TongWang Inc.
 *	$Id: theme_show.tpl.php 2 2013-04-27 07:14:17Z nanown@qq.com $
 */
	defined('IN_TWCMS') || exit('Access Denied');
	include load_tpl('head');
?>
	<div class="head">
		<dl>
			<!-- <input type="button" value="上传主题" class="but1" /> -->
			<dd class="on">主题设置</dd>
			<dd>在线获取</dd>
		</dl>
	</div>
	
	<div class="p c2">
		<div class="cc">
			<?php
				if(empty($this->themeAll)) {
					skyTips('暂无主题');
				}else{
					if(array_key_exists($this->G['theme'], $this->themeAll)) {
						$lv = $this->themeAll[$this->G['theme']];
			?>
			<div class="thm thmon">
				<div class="to">
					<p class="tu"><img src="<?=TWCMS_DIR?>/theme/<?=$this->G['theme']?>/show.jpg" /></p>
					<p class="full"><b>版本号：<?=$lv['version']?></b><b>更新于：<?=$lv['update']?></b><?=$lv['description']?></p>
				</div>
				<h1><?=$lv['name']?>(<?=$this->G['theme']?>)</h1>
				<p class="author">作者: <?php if(empty($lv['authorurl'])) { ?><?=$lv['author']?><?php }else{ ?><a target="_blank" href="<?=$lv['authorurl']?>"><?=$lv['author']?></a><?php } ?></p>
				<p class="gsm" theme="<?=$this->G['theme']?>">
					<b>当前使用</b>
					<a class="edit">编辑</a>
				</p>
			</div>
			<?php
					unset($this->themeAll[$this->G['theme']], $lv);
				}
				foreach($this->themeAll as $dirname=>$lv) {
					
			?>
			<div class="thm">
				<div class="to">
					<p class="tu"><img src="<?=TWCMS_DIR?>/theme/<?=$dirname?>/show.jpg" /></p>
					<p class="full"><b>版本号：<?=$lv['version']?></b><b>更新于：<?=$lv['update']?></b><?=$lv['description']?></p>
				</div>
				<h1><?=$lv['name']?>(<?=$dirname?>)</h1>
				<p class="author">作者: <?php if(empty($lv['authorurl'])) { ?><?=$lv['author']?><?php }else{ ?><a target="_blank" href="<?=$lv['authorurl']?>"><?=$lv['author']?></a><?php } ?></p>
				<p class="gsm" theme="<?=$dirname?>">
					<a class="del">删除</a>
					<a class="enable">启用</a>
					<a class="edit">编辑</a>
				</p>
			</div>
			<?php }} ?>
		</div>
		<div class="cc un"><?php skyTips('近期开放！');?></div>
	</div>
</div>
<script type="text/javascript">
$(".gsm>a").attr("href","javascript:;");
if(!($.browser.msie && $.browser.version<8) && $(".to").length>8) $(".cc").css("padding-bottom", "0");
$(".thm").hover(function(){$(this).addClass("thm_x");}, function(){$(this).removeClass("thm_x");});
$(".thm>.to").hover(
	function(){$(this).children(".tu").hide(); $(this).children(".full").show();},
	function(){$(this).children(".tu").show(); $(this).children(".full").hide();}
);

//启用
$(".gsm>a[class='enable']").click(function(){
	twAjax.postd("<?=ADMNAME?>?mod=setting&action=ajaxpost", {"theme" : $(this).parent().attr("theme")}, function(data){
		twAjax.alert(data);
		if(window.twD.err==0) setTimeout("window.location.reload()",1000);
	});
});

//编辑
$(".gsm>a[class='edit']").each(function(){
	$(this).attr("href","<?=ADMNAME?>?mod=theme&action=modify&theme="+$(this).parent().attr("theme"));
});

//删除
$(".gsm>a[class='del']").click(function(){
	var theme = $(this).parent().attr("theme");
	twAjax.confirm("删除不可恢复，确定删除“<font color='red'>"+$(this).parent().parent().children("h1").html()+"</font>”？", function(){
		twAjax.postd("<?=ADMNAME?>?mod=theme&action=show&ajax=del", {"theme" : theme}, function(data){
			window.twErr = true;
			twAjax.alert(data);
			$(".ajaxtips u").click(function(){window.location.reload()});
			if(window.twD.err==0) setTimeout("window.location.reload()",2000);
		});
	});
});
</script>
</body>
</html>